package com.qixin.modules.eaLoan.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qixin.modules.ea.entity.EaCostItem;
import com.qixin.modules.ea.mapper.EaCostItemMapper;
import com.qixin.modules.ea.vo.ListPageVo;
import com.qixin.modules.eaBasic.entity.EaTask;
import com.qixin.modules.eaBasic.mapper.EaTaskMapper;
import com.qixin.modules.eaBasic.util.ChangeIdToNameUtil;
import com.qixin.modules.eaBasic.util.WorkFlowUtil;
import com.qixin.modules.eaBasic.vo.EaTaskVo;
import com.qixin.modules.eaLoan.entity.EaLoanbill;
import com.qixin.modules.eaLoan.entity.EaLoanbillDetail;
import com.qixin.modules.eaLoan.entity.EaRepaymentbill;
import com.qixin.modules.eaLoan.mapper.EaLoanbillDetailMapper;
import com.qixin.modules.eaLoan.mapper.EaLoanbillMapper;
import com.qixin.modules.eaLoan.mapper.EaRepaymentbillMapper;
import com.qixin.modules.eaLoan.service.IEaRepaymentbillServiceCopy;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.*;

/**
 * @Description: 还款单
 * @Author: qixin-boot
 * @Date:   2021-07-20
 * @Version: V1.0
 */
@Service
public class EaRepaymentbillServiceImplCopy extends ServiceImpl<EaRepaymentbillMapper, EaRepaymentbill> implements IEaRepaymentbillServiceCopy {

	@Autowired
	private EaRepaymentbillMapper eaRepaymentbillMapper;
	@Autowired
	private EaLoanbillDetailMapper eaLoanbillDetailMapper;
	@Value(value = "${server.fileurl}")
	private String fileurl;
	@Autowired
	private EaTaskMapper eaTaskMapper;
	@Autowired
	private ChangeIdToNameUtil changeIdToNameUtil;
	@Autowired
	private EaLoanbillMapper eaLoanbillMapper;
	@Autowired
	private EaCostItemMapper eaCostItemMapper;
	@Autowired
	private WorkFlowUtil workFlowUtil;

	//新增还款单
	@Override
	@Transactional
	public Map<String,Object> saveMain(EaRepaymentbill eaRepaymentbill,List<EaLoanbill> eaLoanbillDetailList) {
		Map<String,Object> returnMap = new HashMap<String,Object>();
		Object result = FillRuleUtil.executeRule("RepaymentCodeRule", null);  //获取单据编号
		eaRepaymentbill.setBillNo(result.toString());

		String saveType = eaRepaymentbill.getSaveType();
		if(saveType.equals("add")) {  //add保存,send提交
			eaRepaymentbill.setState(0);   //单据状态:0未提交,1审批中,2已审批,3已退回
		}else{
			eaRepaymentbill.setState(1);   //单据状态:0未提交,1审批中,2已审批,3已退回
		}

		eaRepaymentbill.setId(Uuid32Util.getUUid());  //主键
		eaRepaymentbillMapper.insert(eaRepaymentbill);

		//保存借款单明细
//		if(eaLoanbillDetailList != null && eaLoanbillDetailList.size() > 0){
//			for (int i = 0; i < eaLoanbillDetailList.size(); i++) {
//				EaLoanbillDetail eaLoanbillDetail = eaLoanbillDetailList.get(i);
//				eaLoanbillDetail.setId(Uuid32Util.getUUid());
//				eaLoanbillDetail.setEaRepaymentbillId(eaRepaymentbill.getId());    //还款单id
//				eaLoanbillDetail.setReveralAmount(eaLoanbillDetail.getLoanBillAmount());  //冲销余额
//				eaLoanbillDetail.setCurrentRemainAmount(new BigDecimal(0));  //当前需还金额
//				eaLoanbillDetail.setRemainAmount(new BigDecimal(0));  //余额
//				eaLoanbillDetailMapper.insert(eaLoanbillDetail);
//				//更新相应的借款单的状态为已使用
//				EaLoanbill eaLoanbill = eaLoanbillMapper.selectById(eaLoanbillDetail.getEaLoanbillId());
//				eaLoanbill.setIsused("1");    //设置已使用
//				eaLoanbillMapper.updateById(eaLoanbill);
//			}
//		}

		//新增待办
		EaTask eaTask = new EaTask();
		eaTask.setId(Uuid32Util.getUUid());
		eaTask.setFormType("3");  //单据类型:1差旅费报销单,2借款单,3还款单,4出差申请单,5出差申请变更单,6招待费申请单,7招待费申请变更单,8招待费报销单,9资金支付审批单,10通讯报销单,11电话记录单
		eaTask.setAuditManId(eaRepaymentbill.getAuditManId());   //审批人id
		eaTask.setAuditMan(eaRepaymentbill.getAuditMan());    //审批人
		//提交类型:保存:add,提交:send
		if(saveType.equals("add")){  //add保存,send提交
			eaTask.setStatus("0");
		}else{
			eaTask.setStatus("1");
		}
		eaTask.setFormId(eaRepaymentbill.getId());    //单据id
		eaTask.setFormCode(eaRepaymentbill.getBillNo());   //单据编号
		eaTask.setMemo("");    //备注
		eaTask.setTotalFee(eaRepaymentbill.getRepaymentAmount()); //总金额
		eaTask.setSort("3");   //排序
		eaTask.setTitle("还款单");  //标题
		eaTask.setSendManId(eaRepaymentbill.getPersonId());    //发送人id
		eaTask.setSendMan(changeIdToNameUtil.getPsnNameById(eaRepaymentbill.getPersonId()));    //发送人
		eaTask.setSendDepartId(eaRepaymentbill.getDeptId());  //发送人部门id
		eaTask.setSendDepart(changeIdToNameUtil.getNameByDepartId(eaRepaymentbill.getDeptId()));   //发送人部门
		eaTask.setSendTime(new Date());    //发送时间
		eaTaskMapper.insert(eaTask);

		returnMap.put("id",eaRepaymentbill.getId());
		returnMap.put("code","0");
		returnMap.put("message","保存成功!");
		return returnMap;
	}

	//编辑还款单
	@Override
	@Transactional
	public Map<String,Object> updateMain(EaRepaymentbill eaRepaymentbill,List<EaLoanbill> eaLoanbillDetailList) {
		Map<String,Object> returnMap = new HashMap<String,Object>();

		//如果picture中有http://localhost:9092/qixin-boot/aaa.png,要处理只保留文件名
		String picture = eaRepaymentbill.getPicture() != null ? eaRepaymentbill.getPicture().toString() : "";
		String picture_final = picture.replaceAll(fileurl,"");;
		//设置最终的图片如:1111.png,2222.png
		eaRepaymentbill.setPicture(picture_final);

		String saveType = eaRepaymentbill.getSaveType();
		if(saveType.equals("add")) {  //add保存,send提交
			EaRepaymentbill eaRepaymentbill1 = eaRepaymentbillMapper.selectById(eaRepaymentbill.getId());
			eaRepaymentbill.setState(eaRepaymentbill1.getState());   //单据状态:0未提交,1审批中,2已审批,3已退回
		}else{
			eaRepaymentbill.setState(1);   //单据状态:0未提交,1审批中,2已审批,3已退回
		}

		eaRepaymentbillMapper.updateById(eaRepaymentbill);

		//更新原添加的借款单使用状态为0
		Map<String,Object> params2 = new HashMap<String,Object>();
		params2.put("ea_repaymentbill_id",eaRepaymentbill.getId());
		List<EaLoanbillDetail> eaLoanbillDetailList2 = eaLoanbillDetailMapper.selectByMap(params2);
		for (int i = 0; i < eaLoanbillDetailList2.size(); i++) {
			EaLoanbillDetail eaLoanbillDetail = eaLoanbillDetailList2.get(i);
			//更新相应的借款单的状态为未使用
			EaLoanbill eaLoanbill = eaLoanbillMapper.selectById(eaLoanbillDetail.getEaLoanbillId());
			eaLoanbill.setIsused("0");    //设置未使用
			eaLoanbillMapper.updateById(eaLoanbill);
		}

		//再删除相应的借款单
		Map<String,Object> params = new HashMap<String,Object>();
		params.put("ea_repaymentbill_id",eaRepaymentbill.getId());
		eaLoanbillDetailMapper.deleteByMap(params);

//		//再保存借款单明细
//		if(eaLoanbillDetailList != null && eaLoanbillDetailList.size() > 0){
//			for (int i = 0; i < eaLoanbillDetailList.size(); i++) {
//				EaLoanbillDetail eaLoanbillDetail = eaLoanbillDetailList.get(i);
//				eaLoanbillDetail.setId(Uuid32Util.getUUid());
//				eaLoanbillDetail.setEaRepaymentbillId(eaRepaymentbill.getId());    //还款单id
//				eaLoanbillDetail.setReveralAmount(eaLoanbillDetail.getLoanBillAmount());  //冲销余额
//				eaLoanbillDetail.setCurrentRemainAmount(new BigDecimal(0));  //当前需还金额
//				eaLoanbillDetail.setRemainAmount(new BigDecimal(0));  //余额
//				eaLoanbillDetailMapper.insert(eaLoanbillDetail);
//				//更新相应的借款单的状态为已使用
//				EaLoanbill eaLoanbill = eaLoanbillMapper.selectById(eaLoanbillDetail.getEaLoanbillId());
//				eaLoanbill.setIsused("1");    //设置已使用
//				eaLoanbillMapper.updateById(eaLoanbill);
//			}
//		}

		//修改待办
		Map<String,Object> paramsMap2 = new HashMap<String,Object>();
		paramsMap2.put("form_id",eaRepaymentbill.getId());
		List<EaTask> eaTaskList = eaTaskMapper.selectByMap(paramsMap2);
		for (EaTask eaTask:eaTaskList) {
			eaTask.setAuditManId(eaRepaymentbill.getAuditManId());   //审批人id
			eaTask.setAuditMan(eaRepaymentbill.getAuditMan());    //审批人
			//提交类型:保存:add,提交:send
			if(saveType.equals("add")){  //add保存,send提交
				eaTask.setStatus("0");
			}else{
				eaTask.setStatus("1");
			}
			eaTask.setFormId(eaRepaymentbill.getId());    //单据id
			eaTask.setFormCode(eaRepaymentbill.getBillNo());   //单据编号
			eaTask.setMemo("");    //备注
			eaTask.setTotalFee(eaRepaymentbill.getRepaymentAmount()); //总金额
			eaTask.setSendManId(eaRepaymentbill.getPersonId());    //发送人id
			eaTask.setSendMan(changeIdToNameUtil.getPsnNameById(eaRepaymentbill.getPersonId()));    //发送人
			eaTask.setSendDepartId(eaRepaymentbill.getDeptId());  //发送人部门id
			eaTask.setSendDepart(changeIdToNameUtil.getNameByDepartId(eaRepaymentbill.getDeptId()));   //发送人部门
			eaTask.setSendTime(new Date());    //发送时间
			eaTaskMapper.updateById(eaTask);
		}

		returnMap.put("id",eaRepaymentbill.getId());
		returnMap.put("code","0");
		returnMap.put("message","编辑成功!");
		return returnMap;
	}

	@Override
	@Transactional
	public void delMain(String id) {
		//更新原添加的借款单使用状态为0
		Map<String,Object> params2 = new HashMap<String,Object>();
		params2.put("ea_repaymentbill_id",id);
		List<EaLoanbillDetail> eaLoanbillDetailList2 = eaLoanbillDetailMapper.selectByMap(params2);
		for (int i = 0; i < eaLoanbillDetailList2.size(); i++) {
			EaLoanbillDetail eaLoanbillDetail = eaLoanbillDetailList2.get(i);
			//更新相应的借款单的状态为未使用
			EaLoanbill eaLoanbill = eaLoanbillMapper.selectById(eaLoanbillDetail.getEaLoanbillId());
			eaLoanbill.setIsused("0");    //设置未使用
			eaLoanbillMapper.updateById(eaLoanbill);
		}

		eaLoanbillDetailMapper.deleteByMainId(id);
		eaRepaymentbillMapper.deleteById(id);

		//删除相应的待办
		Map<String,Object> paramaMap = new HashMap<String,Object>();
		paramaMap.put("form_id",id);
		List<EaTask> eaTaskList = eaTaskMapper.selectByMap(paramaMap);
		if(eaTaskList != null && eaTaskList.size() > 0){
			EaTask eaTask = eaTaskList.get(0);

			//删除相应的工作流
			workFlowUtil.deleteWorkFlowById(eaTask.getWorkflowTaskId(),eaTask.getProcinstId());

			eaTaskMapper.deleteById(eaTask.getId());
		}
	}

	@Override
	@Transactional
	public void delBatchMain(Collection<? extends Serializable> idList) {
		for(Serializable id:idList) {
			eaLoanbillDetailMapper.deleteByMainId(id.toString());
			eaRepaymentbillMapper.deleteById(id);
		}
	}

	//查询还款单列表
	@Override
	public Map<String, Object> list(ListPageVo listPageVo) {
		LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
		Map<String,Object> map = new HashMap<String,Object>();
		String page = EmptyUtil.checkNull(listPageVo.getPage());
		String limit = EmptyUtil.checkNull(listPageVo.getLimit());
		String keyword = EmptyUtil.checkNull(listPageVo.getKeyword());
		String userid = EmptyUtil.checkNull(loginUser.getId());   //用户id
		String status = EmptyUtil.checkNull(listPageVo.getStatus());   //状态
		String billNo = EmptyUtil.checkNull(listPageVo.getBillNo());   //单据编号(pc)
		String billDateBegin = EmptyUtil.checkNull(listPageVo.getBillDateBegin());   //单据日期-开始(pc)
		String billDateEnd = EmptyUtil.checkNull(listPageVo.getBillDateEnd());   //单据日期-结束(pc)
		String personId = EmptyUtil.checkNull(listPageVo.getPersonId());   //申请人/报销人/借款人/还款人(pc)
		String explainStr = EmptyUtil.checkNull(listPageVo.getCasue());   //事由(pc)
		String sysOrgCode = EmptyUtil.checkNull(listPageVo.getSysOrgCode());   //所属组织(pc)
		String keyword1 = "%" + keyword + "%";
		map.put("keyword",keyword1);
		map.put("page",(Integer.parseInt(page) -1) * Integer.parseInt(limit));
		map.put("limit",Integer.parseInt(limit));
		map.put("userid",userid);
		map.put("status",status);
		map.put("billNo",billNo);
		map.put("billDateBegin",billDateBegin);
		map.put("billDateEnd",billDateEnd);
		map.put("personId",personId);
		map.put("explainStr",explainStr);
		map.put("sysOrgCode",sysOrgCode);
		List<EaRepaymentbill> eaRepaymentbillList = eaRepaymentbillMapper.selectRepaymentBills(map);

		List<Map<String,Object>> returnList = new ArrayList<Map<String,Object>>();
		if(eaRepaymentbillList != null && eaRepaymentbillList.size() > 0){
			for (int i = 0; i < eaRepaymentbillList.size(); i++) {
				Map<String,Object> returnMap = new HashMap<String,Object>();
				returnMap = JSON.parseObject(JSON.toJSONString(eaRepaymentbillList.get(i), SerializerFeature.WriteMapNullValue), Map.class);

				//格式化时间
				Long createTime = returnMap.get("createTime") != null ? Long.parseLong(returnMap.get("createTime").toString()) : null;
				String createTimeStr = DateFormatUtil.formatDateyyMMddHHmmss(createTime);
				returnMap.put("createTime",createTimeStr);

				//格式化时间
				Long updateTime = returnMap.get("updateTime") != null ? Long.parseLong(returnMap.get("updateTime").toString()) : null;
				String updateTimeStr = DateFormatUtil.formatDateyyMMddHHmmss(updateTime);
				returnMap.put("updateTime",updateTimeStr);

				//更新时间-用于校验时效性
				map.put("time",updateTimeStr);

				//格式化时间
				Long billDate = returnMap.get("billDate") != null ? Long.parseLong(returnMap.get("billDate").toString()) : null;
				String billDateStr = DateFormatUtil.formatDateyyMMdd(billDate);
				returnMap.put("billDate",billDateStr);

				returnList.add(returnMap);
			}
		}

		int count = 0;
		map.put("page",0);
		map.put("limit",0);
		map.put("keyword",keyword1);
		map.put("userid",userid);
		List<EaRepaymentbill> list2 = eaRepaymentbillMapper.selectRepaymentBills(map);
		count = list2.size();
		Map<String,Object> returnMap = new HashMap<String,Object>();
		returnMap.put("records",eaRepaymentbillList);
		returnMap.put("total",count);
		return returnMap;
	}

	//查询还款单详情
	@Override
	public Map<String, Object> selectById(String id) {
		//查询还款单详情
		Map<String,Object> queryWrapper = new HashMap<String,Object>();
		queryWrapper.put("id",id);  //还款单id
		queryWrapper.put("page",0);
		queryWrapper.put("limit",0);
		List<EaRepaymentbill> eaBillsList = eaRepaymentbillMapper.selectRepaymentBills(queryWrapper);
		Map<String,Object> returnMap = new HashMap<String,Object>();
		if(eaBillsList != null && eaBillsList.size() > 0){
			returnMap = JSON.parseObject(JSON.toJSONString(eaBillsList.get(0), SerializerFeature.WriteMapNullValue), Map.class);

			//格式化时间
			Long createTime = returnMap.get("createTime") != null ? Long.parseLong(returnMap.get("createTime").toString()) : null;
			String createTimeStr = DateFormatUtil.formatDateyyMMddHHmmss(createTime);
			returnMap.put("createTime",createTimeStr);

			//格式化时间
			Long updateTime = returnMap.get("updateTime") != null ? Long.parseLong(returnMap.get("updateTime").toString()) : null;
			String updateTimeStr = DateFormatUtil.formatDateyyMMddHHmmss(updateTime);
			returnMap.put("updateTime",updateTimeStr);

			//更新时间-用于校验时效性
			returnMap.put("time",updateTimeStr);

			//格式化时间
			Long billDate = returnMap.get("billDate") != null ? Long.parseLong(returnMap.get("billDate").toString()) : null;
			String billDateStr = DateFormatUtil.formatDateyyMMdd(billDate);
			returnMap.put("billDate",billDateStr);

			//添加图片
			String picture = returnMap.get("picture") != null ? returnMap.get("picture").toString() : "";
			List<Map<String,Object>> fileList = GetUrlUtil.getUrl(picture,fileurl);

			//添加图片fileList
			returnMap.put("fileList",fileList);

			//查询借款单信息
			Map<String,Object> repayParams = new HashMap<String,Object>();
			repayParams.put("ea_repaymentbill_id",id);
			List<EaLoanbillDetail> eaLoanbillDetailList = eaLoanbillDetailMapper.selectByMap(repayParams);
			List<Map<String,Object>> eaLoanbillDetailMapList = new ArrayList<Map<String,Object>>();
			if(eaLoanbillDetailList != null && eaLoanbillDetailList.size() > 0){
				for (int i = 0; i < eaLoanbillDetailList.size(); i++) {
					Map<String,Object> eaLoanbillDetailMap = JSON.parseObject(JSON.toJSONString(eaLoanbillDetailList.get(i), SerializerFeature.WriteMapNullValue), Map.class);
					//创建人
					eaLoanbillDetailMap.put("createByName",changeIdToNameUtil.getNameById(EmptyUtil.checkNull(eaLoanbillDetailMap.get("createBy"))));
					//更新人
					eaLoanbillDetailMap.put("updateByName",changeIdToNameUtil.getNameById(EmptyUtil.checkNull(eaLoanbillDetailMap.get("updateBy"))));

					//格式化时间
					Long createTime1 = eaLoanbillDetailMap.get("createTime") != null ? Long.parseLong(eaLoanbillDetailMap.get("createTime").toString()) : null;
					String createTime1Str = DateFormatUtil.formatDateyyMMddHHmmss(createTime1);
					eaLoanbillDetailMap.put("createTime",createTime1Str);

					//格式化时间
					Long updateTime1 = eaLoanbillDetailMap.get("updateTime") != null ? Long.parseLong(eaLoanbillDetailMap.get("updateTime").toString()) : null;
					String updateTime1Str = DateFormatUtil.formatDateyyMMddHHmmss(updateTime1);
					eaLoanbillDetailMap.put("updateTime",updateTime1Str);

					//格式化时间
					Long loanBillDate = eaLoanbillDetailMap.get("loanBillDate") != null ? Long.parseLong(eaLoanbillDetailMap.get("loanBillDate").toString()) : null;
					String loanBillDateStr = DateFormatUtil.formatDateyyMMdd(loanBillDate);
					eaLoanbillDetailMap.put("loanBillDate",loanBillDateStr);

					//费用项目
					String indexId = eaLoanbillDetailMap.get("indexId") != null ? eaLoanbillDetailMap.get("indexId").toString() : "";
					EaCostItem eaCostItem = eaCostItemMapper.selectById(indexId);
					if(eaCostItem != null){
						eaLoanbillDetailMap.put("indexIdName",eaCostItem.getItemName());
					}else{
						eaLoanbillDetailMap.put("indexIdName","");
					}

					//添加借款单明细
					eaLoanbillDetailMapList.add(eaLoanbillDetailMap);
				}
			}

			//将借款单信息加入返回节点
			returnMap.put("eaLoanbillDetailList",eaLoanbillDetailMapList);
		}

		return returnMap;
	}

	@Override
	@Transactional
	public Map<String, Object> audit(EaTaskVo eaTaskVo) {
		Map<String,Object> returnMap = new HashMap<String,Object>();
		String id = EmptyUtil.checkNull(eaTaskVo.getId());   //单据id
//        String auditManId = EmptyUtil.checkNull(eaTaskVo.getAuditManId());   //审批人id
//        String auditMan = EmptyUtil.checkNull(eaTaskVo.getAuditMan());   //审批人
		String auditComment = EmptyUtil.checkNull(eaTaskVo.getAuditComment());   //审批意见
		String status = EmptyUtil.checkNull(eaTaskVo.getStatus());   //单据状态:2通过,3退回

		//获取还款单-更新状态
		EaRepaymentbill eaRepaymentbill = eaRepaymentbillMapper.selectById(id);
		eaRepaymentbill.setState(Integer.parseInt(status));
		eaRepaymentbillMapper.updateById(eaRepaymentbill);

		Map<String,Object> paramsMap = new HashMap<String,Object>();
		paramsMap.put("form_id",eaRepaymentbill.getId());
		List<EaTask> eaTaskList = eaTaskMapper.selectByMap(paramsMap);
		if(eaTaskList != null && eaTaskList.size() > 0){
			EaTask eaTask = eaTaskList.get(0);
			//eaTask.setAuditManId(auditManId);
			//eaTask.setAuditMan(auditMan);
			eaTask.setAuditComment(auditComment);
			eaTask.setStatus(status);

			try {
				if(status.equals("3") || status.equals("2")){
					eaTask.setFinishTime(new Date());   //完成时间

					//审批退回时,更新关联的借款单为未使用状态
					if(status.equals("3")){
						List<EaLoanbillDetail> eaLoanbillDetailList = eaLoanbillDetailMapper.selectByMainId(eaRepaymentbill.getId());
						if(eaLoanbillDetailList.size() > 0){
							for (int i = 0; i < eaLoanbillDetailList.size(); i++) {
								EaLoanbillDetail eaLoanbillDetail = eaLoanbillDetailList.get(i);
								EaLoanbill eaLoanbill = eaLoanbillMapper.selectById(eaLoanbillDetail.getEaLoanbillId());
								eaLoanbill.setIsused("0");   //设置借款单未使用
								eaLoanbillMapper.updateById(eaLoanbill);
							}
						}
					}
				}
				eaTask.setAuditTime(new Date());    //审批时间
				eaTaskMapper.updateById(eaTask);

				returnMap.put("code","0");
				returnMap.put("message","审核成功!");
				return returnMap;
			}catch (Exception e){
				returnMap.put("code","-1");
				returnMap.put("message","系统异常,审核失败!");
				return returnMap;
			}
		}else{
			returnMap.put("code","-1");
			returnMap.put("message","待办不存在!");
			return returnMap;
		}
	}

	@Override
	public EaRepaymentbill queryById(String billId) {
		return eaRepaymentbillMapper.selectById(billId);
	}

}
